package com.ruoyi.shangpinxinxi.service.impl;

import java.util.List;

import com.ruoyi.shangpinxinxi.domain.TestResult;
import com.ruoyi.shangpinxinxi.service.IShangpinxinxiService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.shangpinxinxi.mapper.ShangpinxinxiMapper;
import com.ruoyi.shangpinxinxi.domain.Shangpinxinxi;
import com.ruoyi.common.core.text.Convert;

/**
 * 商品信息Service业务层处理
 * 
 * @author ruoyi
 * @date 2023-05-17
 */
@Service
public class ShangpinxinxiServiceImpl implements IShangpinxinxiService
{
    @Autowired
    private ShangpinxinxiMapper shangpinxinxiMapper;

    /**
     * 查询商品信息
     * 
     * @param id 商品信息主键
     * @return 商品信息
     */
    @Override
    public Shangpinxinxi selectShangpinxinxiById(Long id)
    {
        return shangpinxinxiMapper.selectShangpinxinxiById(id);
    }

    /**
     * 查询商品信息列表
     * 
     * @param shangpinxinxi 商品信息
     * @return 商品信息
     */
    @Override
    public List<Shangpinxinxi> selectShangpinxinxiList(Shangpinxinxi shangpinxinxi)
    {
        return shangpinxinxiMapper.selectShangpinxinxiList(shangpinxinxi);
    }

    /**
     * 新增商品信息
     * 
     * @param shangpinxinxi 商品信息
     * @return 结果
     */
    @Override
    public int insertShangpinxinxi(Shangpinxinxi shangpinxinxi)
    {
        return shangpinxinxiMapper.insertShangpinxinxi(shangpinxinxi);
    }

    /**
     * 修改商品信息
     * 
     * @param shangpinxinxi 商品信息
     * @return 结果
     */
    @Override
    public int updateShangpinxinxi(Shangpinxinxi shangpinxinxi)
    {
        return shangpinxinxiMapper.updateShangpinxinxi(shangpinxinxi);
    }

    /**
     * 批量删除商品信息
     * 
     * @param ids 需要删除的商品信息主键
     * @return 结果
     */
    @Override
    public int deleteShangpinxinxiByIds(String ids)
    {
        return shangpinxinxiMapper.deleteShangpinxinxiByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除商品信息信息
     * 
     * @param id 商品信息主键
     * @return 结果
     */
    @Override
    public int deleteShangpinxinxiById(Long id)
    {
        return shangpinxinxiMapper.deleteShangpinxinxiById(id);
    }

    @Override
    public Shangpinxinxi selectShangpinxinxi2men4Name(String goodNameMen) {
        return shangpinxinxiMapper.selectShangpinxinxi2men4Name(goodNameMen);
    }

    @Override
    public Shangpinxinxi selectShangpinxinxi2kuang4Name(String goodNameKuang) {
        return shangpinxinxiMapper.selectShangpinxinxi2kuang4Name(goodNameKuang);
    }

    @Override
    public Shangpinxinxi selectShangpinxinxi2zhengmen4Name(String goodNameMen) {
        return shangpinxinxiMapper.selectShangpinxinxi2zhengmen4Name(goodNameMen);
    }

    @Override
    public List<Shangpinxinxi> selectShangpinxinxiByTestResult(TestResult testResult) {
        String name = testResult.getMenName();
        if (name.equals("%防火锁%") || name.equals("%拉爆盖%") || name.equals("%闭门器%")) {
            return shangpinxinxiMapper.selectShangpinxinxiByNameAndSize2(testResult);
        }else {
            return shangpinxinxiMapper.selectShangpinxinxiByTestResult(testResult);
        }

    }

    @Override
    public List<Shangpinxinxi> selectShangpinxinxiByNameAndSize2(TestResult wujin1t) {
        return shangpinxinxiMapper.selectShangpinxinxiByNameAndSize2(wujin1t);
    }

    @Override
    public List<Shangpinxinxi> selectShangpinxinxi2LaBaoGai4Name(String leixing) {
        String newlei = "%"+leixing+"%";
        return shangpinxinxiMapper.selectShangpinxinxi2LaBaoGai4Name(newlei);
    }

    @Override
    public Shangpinxinxi selectShangpinxinxiByDanhao(String msg) {
        return shangpinxinxiMapper.selectShangpinxinxiByDanhao(msg);
    }
}
